/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ania2.engine.utils;

import java.util.Random;

/**
 *
 * @author pawel
 */
public class ZobristHashTables {

    public static final long[][] HASH_CODE_TABLE;
    public static final long[][] LOCK_CODE_TABLE;
    

    static {
        HASH_CODE_TABLE = new long[64][4];
        LOCK_CODE_TABLE = new long[64][4];
        Random rand = new Random(47);
        for (int i = 0; i < 64; i++) {
            for (int j = 0; j < 4; j++) {
                long hash = rand.nextLong();
                long lock = rand.nextLong();
                boolean uniqueHash = false;
                boolean uniqueLock = false;
                while (!uniqueHash) {
                    uniqueHash = true;
                    for (int i2 = 0; i2 < i; i2++) {
                        for (int j2 = 0; j2 < j; j2++) {
                            if (HASH_CODE_TABLE[i2][j2] == hash) {
                                uniqueHash = false;
                            }
                        }
                    }
                }
                HASH_CODE_TABLE[i][j] = hash;
                while (!uniqueLock) {
                    uniqueLock = true;
                    for (int i2 = 0; i2 < i; i2++) {
                        for (int j2 = 0; j2 < j; j2++) {
                            if (LOCK_CODE_TABLE[i2][j2] == lock) {
                                uniqueLock = false;
                            }
                        }
                    }
                }
                LOCK_CODE_TABLE[i][j] = lock;
            }
        }
    }
}
